package kr.hkit.androidcomplete01.chapter06;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class NewMessageInflate extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.ch06_newnessageinflate);
		
		Button btn = (Button)findViewById(R.id.btnnewmsg);
	}
	
	public void mOnClick(View v){
		RelativeLayout msg = (RelativeLayout)View.inflate(
				NewMessageInflate.this, R.layout.newmessage, null);
		LinearLayout linear = (LinearLayout)findViewById(R.id.linear);
		if(linear.getChildCount() % 2 == 0){
			msg.setBackgroundColor(Color.GRAY);
		}else{
			msg.setBackgroundColor(Color.RED);
		}
		linear.addView(msg);
	}
}
